<?php

namespace IDock\Insurance\AMIC;

use IDock\IDock\IDockInterface;
use IDock\Insurance\AMIC\Request\EPolicyDownloadRequest;
use IDock\Insurance\AMIC\Request\PolicyPaymentRequest;
use IDock\Insurance\AMIC\Request\PremiumInquiryRequest;
use IDock\Insurance\AMIC\Request\RenewalInquiryRequest;
use IDock\Insurance\AMIC\Request\UnderwritingRequest;
use IDock\Insurance\AMIC\Request\UploadFileRequest;
use IDock\Insurance\AMIC\Request\VehicleConfirmRequest;
use IDock\Insurance\AMIC\Request\VehicleModelRequest;
use IDock\Insurance\AMIC\Response\EPolicyDownloadResponse;
use IDock\Insurance\AMIC\Response\NonCarProductListResponse;
use IDock\Insurance\AMIC\Response\PolicyPaymentResponse;
use IDock\Insurance\AMIC\Response\PremiumInquiryResponse;
use IDock\Insurance\AMIC\Response\RenewalInquiryResponse;
use IDock\Insurance\AMIC\Response\UnderwritingResponse;
use IDock\Insurance\AMIC\Response\VehicleActualValueResponse;
use IDock\Insurance\AMIC\Response\VehicleConfirmResponse;
use IDock\Insurance\AMIC\Response\VehicleModelResponse;
use IDock\Printer\NonCar\NonCarInquiryPrinter;
use IDock\Printer\NonCar\NonCarInquirySinglePrinter;
use IDock\Printer\Premium\PremiumInquiryPrinter;
use IDock\Printer\PremiumUnderwritingPrinter;
use IDock\Printer\SpecialClausesPrinter;
use IDock\Printer\VehicleActualValuePrinter;
use IDock\Visitor\EPolicyDownloadVisitor;
use IDock\Visitor\NonCar\NonCarInquiryVisitor;
use IDock\Visitor\NonCar\NonCarProductListVisitor;
use IDock\Visitor\NonCar\NonCarProductVisitor;
use IDock\Visitor\PolicyInfoVisitor;
use IDock\Visitor\PolicyPaymentVisitor;
use IDock\Visitor\Premium\PremiumInquiryVisitor;
use IDock\Visitor\ProposalRecallVisitor;
use IDock\Visitor\ProposalStatusVisitor;
use IDock\Visitor\RenewalInquiryVisitor;
use IDock\Visitor\UnderwritingRecallVisitor;
use IDock\Visitor\UploadFileVisitor;
use IDock\Visitor\VehicleActualValueVisitor;
use IDock\Visitor\VehicleModelVisitor;

/**
 * 珠峰保险
 */
class AMICConstruct extends Builder implements IDockInterface
{

    protected $config = [];

    public function __construct($config)
    {
        $this->config = $config;
        $this->channelName = $config['channelName'] ?? '';
        $this->appId = $config['appId'] ?? '';
        $this->appKey = $config['appKey'] ?? '';
        $this->planCodeNew = $config['planCodeNew'] ?? '';
    }

    /**
     * 车型查询
     * @param VehicleModelVisitor $vehicleModelVisitor
     * @return VehicleModelResponse
     */
    public function vehicleModel(VehicleModelVisitor $vehicleModelVisitor): VehicleModelResponse
    {
        $request = new VehicleModelRequest();
        $request->setVisitor($vehicleModelVisitor);

        /*** @var VehicleModelResponse $response */
        $response = $this->execute($request);
        $str = explode('牌',$vehicleModelVisitor->vehicleModel);
        $strEnd = end($str);
        $response->filter($strEnd);
        return $response;
    }

    /**
     * 续保查询
     * @param RenewalInquiryVisitor $renewalInquiryVisitor
     * @return RenewalInquiryResponse
     * @version 4.0
     */
    public function renewalInquiry(RenewalInquiryVisitor $renewalInquiryVisitor): RenewalInquiryResponse
    {
        $request = new RenewalInquiryRequest();
        $request->setVisitor($renewalInquiryVisitor);
//        global $testResponse;
/*        $testResponse = '<?xml version="1.0" encoding="utf-8"?><Packet><Head><returnCode>0000</returnCode><returnMsg>业务处理成功</returnMsg><requestType>N0201</requestType><sign>50414f76ab659ea9794b64c4673b6a14</sign><timeStamp>20240628163827</timeStamp></Head><Body><renewBase><orderNo>HXY0ff6a81719563907480</orderNo><amOrderNo></amOrderNo><oldBusiFlag>1</oldBusiFlag></renewBase><oldBusiPolicy><oldBusiPolicyNO>2052895100002023000012</oldBusiPolicyNO><prodNo>0528</prodNo><Isinstantflag>0</Isinstantflag><oldBusiStartDate>20230705000000</oldBusiStartDate><oldBusiEndDate>20240705000000</oldBusiEndDate></oldBusiPolicy><oldCIPolicy><oldCIPolicyNO>2059095100002023000123</oldCIPolicyNO><prodNo>0590</prodNo><Isinstantflag>0</Isinstantflag><oldCIStartDate>20230705000000</oldCIStartDate><oldCIEndDate>20240705000000</oldCIEndDate></oldCIPolicy><vehicle><vehicleId>BYAAYD0002</vehicleId><vehicleName>比亚迪BYD7005BEV纯电动轿车</vehicleName><vehiclePlatId></vehiclePlatId><vehiclePrice>219800.0</vehiclePrice><vehicleActualPrice>211887.2</vehicleActualPrice><noLicenseFlag>0</noLicenseFlag><licensePlateNo>川SSS911</licensePlateNo><licensePlateType>01</licensePlateType><motorTypeCode>11</motorTypeCode><vehicleStyle>K11</vehicleStyle><firstRegisterDate>2022-12-13</firstRegisterDate><vin>LFDE1MN5445411111</vin><engineNo>57054121111111</engineNo><seatCount>5</seatCount><limitLoad>0.0</limitLoad><wholeWeight>1850.0</wholeWeight><displaceMent>0.001</displaceMent><Power>0.0</Power><fuelType>C</fuelType><useNature>85</useNature><drivePermitDate>2019-12-21 00:00:00.0</drivePermitDate></vehicle><applicant><appName>李阳与</appName><appType>1</appType><appNature>1</appNature><certfCls>01</certfCls><certfCode>513823199706131515</certfCode><certfValidStartDate>2008-12-21</certfValidStartDate><certfValidEndDate>2999-12-31</certfValidEndDate><appBirthday>19970613</appBirthday><appMobile>18228376531</appMobile><postCode></postCode><appAddress>四川省成都市大邑县小南街</appAddress><appSex>1</appSex><appNationality></appNationality><appEmail>2471645450@163.com</appEmail><appNation></appNation><appIssuer></appIssuer><appCompanyType></appCompanyType><appAddressCode>510000-510100-510129</appAddressCode></applicant><appInsured><insuredName>李阳与</insuredName><insuredType>1</insuredType><insuredNature>1</insuredNature><certfCls>01</certfCls><certfCode>513823199706131515</certfCode><certfValidStartDate>2008-12-21</certfValidStartDate><certfValidEndDate>2999-12-31</certfValidEndDate><insuredBirthday>19970613</insuredBirthday><insuredMobile>18228376531</insuredMobile><postCode></postCode><insuredAddress>四川省成都市大邑县小南街</insuredAddress><insuredSex>1</insuredSex><insuredNationality></insuredNationality><insuredEmail>2471645450@163.com</insuredEmail><insureNation></insureNation><insureIssuer></insureIssuer><insureCompanyType></insureCompanyType><insureAddressCode>510000-510100-510129</insureAddressCode></appInsured><vehicleOwner><vehicleOwnerName>李阳与</vehicleOwnerName><vehicleOwnerIdentifyType>01</vehicleOwnerIdentifyType><vehicleOwnerIdentifyNumber>513823199706131515</vehicleOwnerIdentifyNumber><certfValidStartDate>2008-12-21</certfValidStartDate><certfValidEndDate>2999-12-31</certfValidEndDate><vehicleOwnerBirth>19970613</vehicleOwnerBirth><vehicleOwnerSex>1</vehicleOwnerSex><vehicleOwnerType>1</vehicleOwnerType><vehicleOwnerMobile>18228376531</vehicleOwnerMobile><vehicleOwnerAddress>四川省成都市大邑县小南街</vehicleOwnerAddress><vehicleAddressCode>510000-510100-510129</vehicleAddressCode><postCode></postCode><vehicleNation></vehicleNation><vehicleIssuer></vehicleIssuer><vehicleOwnerEmail>2471645450@163.com</vehicleOwnerEmail></vehicleOwner><renewItemKind><coverageItem><coverageCode>0401200</coverageCode><sumLimit>211887.20</sumLimit><noDduct></noDduct><glsType></glsType><repairFactoryType></repairFactoryType><rate></rate><unit>0</unit><unitAmount>0.00</unitAmount><unclaimAmount></unclaimAmount><deductibleRate></deductibleRate><serverTime></serverTime><sharedSumInsurd></sharedSumInsurd></coverageItem></renewItemKind></Body></Packet>';*/
        /*** @var RenewalInquiryResponse $response */
        $response = $this->execute($request);
        return $response;
    }

    /**
     * 车辆实际价格接口
     * @param VehicleActualValueVisitor $vehicleActualValueVisitor
     * @return
     */
    public function vehicleActualValue(VehicleActualValueVisitor $vehicleActualValueVisitor)
    {
        $response = new VehicleActualValueResponse();
        $response->setCode('200');
        $vehicleActualValuePrinter = new VehicleActualValuePrinter();
        $response->printer = $vehicleActualValuePrinter;
        return $response;
    }

    /**
     * 询价前置
     * @param PremiumInquiryVisitor $premiumInquiryVisitor
     * @return
     */
    public function preInquiry(PremiumInquiryVisitor $premiumInquiryVisitor)
    {
        $visitor= new RenewalInquiryVisitor();
        $visitor->licenseNo = $premiumInquiryVisitor->getVehicleVisitor()->licenseNo;
        $visitor->vin = $premiumInquiryVisitor->getVehicleVisitor()->vin;
        $visitor->engineNo = $premiumInquiryVisitor->getVehicleVisitor()->engineNo;
        $visitor->argc = $premiumInquiryVisitor->getExtInfoVisitor()->argc;
        return $this->renewalInquiry($visitor);
    }
    public function validateCar(PremiumInquiryVisitor $premiumInquiryVisitor)
    {
        // TODO: Implement validateCar() method.
    }

    /**
     * 询价
     * @param PremiumInquiryVisitor $premiumInquiryVisitor
     * @return
     * @throws \Exception
     */
    public function premiumInquiry(PremiumInquiryVisitor $premiumInquiryVisitor)
    {
        //车型确认
//        global $testResponse;
/*        $testResponse = '<?xml version="1.0" encoding="utf-8"?><Packet><Head><returnCode>0000</returnCode><returnMsg>提核成功</returnMsg><requestType>N0215</requestType><sign></sign><timeStamp></timeStamp></Head><Body><vehicleModelList><vehicleModel><vehicleId>XFABFD0036</vehicleId><vehicleName>雪佛兰SGM7154EAA1轿车</vehicleName><marketaDate>201608</marketaDate><vehicleSeat>5</vehicleSeat><vehiclePrice>152900.00</vehiclePrice><vehicleAlias>迈锐宝1.5T AT豪华版</vehicleAlias><vehicleExhaust>1.4900</vehicleExhaust><remark>手自一体 豪华版 国Ⅴ</remark><vehicleCompleteKerbMass>1.52</vehicleCompleteKerbMass><vehiclePower>125.0</vehiclePower><vehicleLimitLoad></vehicleLimitLoad><vehiclePlatId>BTYOMSUD0017</vehiclePlatId><vehicleCarName>雪佛兰SGM7154EAA1 豪华版</vehicleCarName><vehicleNoticeType>SGM7154EAA1</vehicleNoticeType><IsCESM>0</IsCESM><allowProduct></allowProduct><acturalPrice>75838.40</acturalPrice><carFuelType>A</carFuelType><isNewenergy></isNewenergy><vehicleStyleUniqueId></vehicleStyleUniqueId><riskLevel>D类</riskLevel><riskTypeVehicle>D</riskTypeVehicle><carkindCode>11</carkindCode></vehicleModel></vehicleModelList></Body></Packet>';*/
        $request1 = new VehicleConfirmRequest();
        $request1->setVisitor($premiumInquiryVisitor);
        /**@var VehicleConfirmResponse $response **/
        $response1 = $this->execute($request1);
        if(!$response1->isSuccess()){
            return $response1;
        }
        $model = $response1->printer->toArray();
        $premiumInquiryVisitor->getExtInfoVisitor()->argc['vehiclePlatId'] = $model[0]['item']['vehiclePlatId'] ?? '';
        $premiumInquiryVisitor->getExtInfoVisitor()->argc['actualPrice'] = $model[0]['item']['actualPrice'] ?? '';
        $request = new PremiumInquiryRequest();
        $request->setVisitor($premiumInquiryVisitor);

//global $testResponse;
/*        $testResponse = '<?xml version="1.0" encoding="utf-8"?><Packet><Head><returnCode>0000</returnCode><returnMsg>业务处理成功！</returnMsg><requestType>N0203</requestType><sign>c1d33bac797ea280d81922af41d7e657</sign><timeStamp>20240826140829</timeStamp></Head><Body><qtnBase><orderNo>HXYa65fd91724652508215</orderNo><renewalFlagBusi>0</renewalFlagBusi><questionDescBusi></questionDescBusi><renewalFlagCI>0</renewalFlagCI><questionDescCI></questionDescCI><reCIInsureFlag>0</reCIInsureFlag><reBusiInsureFlag>0</reBusiInsureFlag><platCISuccessFlag>1</platCISuccessFlag><platBusiSuccessFlag>1</platBusiSuccessFlag><platReturnMsgBusi></platReturnMsgBusi><platReturnMsgCI></platReturnMsgCI><reBusiInsurePlatFlag>0</reBusiInsurePlatFlag><checkCode></checkCode><checkCodeCI></checkCodeCI><errorBusi></errorBusi><errorCi></errorCi><checkCarCode>2408261670</checkCarCode><uploadImgFlag>0</uploadImgFlag><imageCode></imageCode><insureDateBi></insureDateBi><insureDateCi></insureDateCi><offerUrl></offerUrl><undwrtDesc></undwrtDesc><splitFlag>0</splitFlag></qtnBase><vehicle><acturalPrice>30000.40</acturalPrice><carMarketPrice></carMarketPrice><carFuelType></carFuelType><marginalCostGrade>E</marginalCostGrade><carMarketPriceLimit>21000.28,39000.52</carMarketPriceLimit></vehicle><applicationBusi><prodNo>0526</prodNo><basedPremium></basedPremium><expectPrm>1249.00</expectPrm><discount>1.5000</discount><discountDesc>无赔优待系数    1.0自主定价系数    1.5</discountDesc><isNewIns>0</isNewIns><claimAdjustReason></claimAdjustReason><noClaimAdjustReason>04</noClaimAdjustReason><adviceDiscount>1.5</adviceDiscount><insureYears>0</insureYears><claimTimes>0</claimTimes><claimAdjustLevel>0</claimAdjustLevel><effectiveDate>202408270000</effectiveDate><expireDate>202508272400</expireDate><proposalNoBI>T052625100002024001334</proposalNoBI><sumVat>70.70</sumVat><sumTniPremium>1178.30</sumTniPremium><ciCommissionRate>0.00</ciCommissionRate></applicationBusi><applicationCI><prodNo>0590</prodNo><basedPremium></basedPremium><expectPrm>950.00</expectPrm><discount>1.0000</discount><isNewIns>0</isNewIns><claimAdjustReason></claimAdjustReason><noClaimAdjustReason>02</noClaimAdjustReason><effectiveDate>202408270000</effectiveDate><expireDate>202508262400</expireDate><proposalNoCI>T059025100002024001900</proposalNoCI><sumVat>53.77</sumVat><sumTniPremium>896.23</sumTniPremium><ciCommissionRate>0.00</ciCommissionRate><claimTimes>0</claimTimes></applicationCI><busiCoverageItemList><busiCoverageItem><coverageCode>0301600</coverageCode><expectPrm>1249.00</expectPrm><sumAmount>2000000.00</sumAmount></busiCoverageItem></busiCoverageItemList><vehicleTaxation><taxConditionCode>T</taxConditionCode><deductionDueCode></deductionDueCode><deductionDueType></deductionDueType><Deduction>0</Deduction><deductionDueProportion>0</deductionDueProportion><taxDepartment></taxDepartment><taxDepartmentName></taxDepartmentName><taxPaymentRecptNo></taxPaymentRecptNo><taxEffBgnTm>2024-01-01</taxEffBgnTm><taxEffEndTm>2024-12-31</taxEffEndTm><AnnualTaxAmount>360.0</AnnualTaxAmount><annualTaxDue>360.0</annualTaxDue><sumTaxDefault>360.0</sumTaxDefault><sumOverdue>43.02</sumOverdue><sumTax>763.02</sumTax><taxpayerIdentifyNumber>51390219960714105X</taxpayerIdentifyNumber><taxpayerName>樊鑫</taxpayerName><taxpayerIdentifyType>1</taxpayerIdentifyType><delinquentTaxDue><annualTax_Type><taxStartDate>20230101</taxStartDate><taxEndDate>20231231</taxEndDate><taxDue>360.0</taxDue><exCeedDate>20240826</exCeedDate><exCeedDaysCount>239</exCeedDaysCount><overDue>43.02</overDue><totalAmount>403.02</totalAmount></annualTax_Type></delinquentTaxDue><TaxRelifFlag></TaxRelifFlag><taxDocumentDate></taxDocumentDate><taxPaidAreaCode></taxPaidAreaCode></vehicleTaxation><appliHealthInsList><appliHealthIns/></appliHealthInsList><reInsureItem><policyNo></policyNo><effectiveDate></effectiveDate><expireDate></expireDate><tciPlyNo></tciPlyNo><tciBeginDate></tciBeginDate><tciEndDate></tciEndDate></reInsureItem><BUSI_CLAIM_LIST><BUSI_CLAIM_DATA/></BUSI_CLAIM_LIST><CI_CLAIM_LIST><CI_CLAIM_DATA/></CI_CLAIM_LIST><lastPolicy><lastEffectiveDate></lastEffectiveDate><lastExpireDate></lastExpireDate><lastCIbillDate></lastCIbillDate><lastCIEffectiveDate></lastCIEffectiveDate><lastCIExpireDate></lastCIExpireDate></lastPolicy><undwrtList><undwrt><riskCode>0590</riskCode><undwrtDesc>4-30-请核实家用车不含损业务边际成本率等级E情况</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0590</riskCode><undwrtDesc>4-17-请核实家用车交三旧车新保业务政策</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0590</riskCode><undwrtDesc>5-55-旧车新保或新车业务，请核实</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0590</riskCode><undwrtDesc>5-56-评级为E类业务请核实业务情况</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0590</riskCode><undwrtDesc>9-01-请核实评级为E级业务</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>1-28-请上传不含车损险业务投保资料</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>4-30-请核实家用车不含损业务边际成本率等级E情况</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>4-10-请核实承保商业险投保人、车主、被保险人年龄</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>4-17-请核实家用车交三旧车新保业务政策</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>5-56-评级为E类业务请核实业务情况</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt><undwrt><riskCode>0526</riskCode><undwrtDesc>9-01-请核实评级为E级业务</undwrtDesc><undwrtDate>2024-08-26</undwrtDate><undwrtresult>返回录入</undwrtresult><undwrtUser>预核保</undwrtUser></undwrt></undwrtList><reInsureItemBusi><policyNo></policyNo><insurerCode></insurerCode><LicensePlateNo></LicensePlateNo><vin></vin><engineNo></engineNo><lastEffectiveDate></lastEffectiveDate><lastExpireDate></lastExpireDate><coverages><Coverage/></coverages></reInsureItemBusi><appClauseList><appClause><clauseCode>BTG00002</clauseCode><clauseName>告知特约</clauseName><context>若车辆号牌、发动机号、车架号及初次登记年月与行驶证或车辆实际情况不符合，保险人不承担保险责任。</context><clauseType>B</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>B2000042</clauseCode><clauseName>保单信息查询特约</clauseName><context>尊敬的客户：自投保次日起，您可以通过本公司网页www.groupama-sdig.com或全天24小时服务热线956001以及营业网点核实保单及理赔等信息。若对查询结果有异议，请及时联系本公司，联系电话956001。</context><clauseType>B</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>BTG00001</clauseCode><clauseName>医疗费用赔付特约</clauseName><context>经保险双方约定，按照《道路交通事故受伤人员临床诊疗指南》和国家基本医疗保险的同类医疗费用标准核定医疗费用的赔偿金额。</context><clauseType>B</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>BTG00003</clauseCode><clauseName>使用性质特约</clauseName><context>非营业车辆如从事营运性运输或租赁活动，发生保险责任范围内的事故，本公司不负责赔偿。</context><clauseType>B</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>BT20210422</clauseCode><clauseName>保费明示特约</clauseName><context>本保单保险费为含税金额，其中不含税保险费1178.30元、增值税70.70元。</context><clauseType>B</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>CT2100</clauseCode><clauseName>告知特约</clauseName><context>本条款适用于《机动车交通事故责任强制保险条款》  ;本保险单系一次性打印，涂改无效。</context><clauseType>C</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>C2000042</clauseCode><clauseName>保单信息查询特约</clauseName><context>尊敬的客户：自投保次日起，您可以通过本公司网页www.groupama-sdig.com或全天24小时服务热线956001以及营业网点核实保单及理赔等信息。若对查询结果有异议，请及时联系本公司，联系电话956001。</context><clauseType>C</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause><appClause><clauseCode>CT20210422</clauseCode><clauseName>保费明示特约</clauseName><context>本保单保险费为含税金额，其中不含税保险费896.23元、增值税 53.77元。</context><clauseType>C</clauseType><updateFlag>0</updateFlag><delFlag>0</delFlag></appClause></appClauseList><programmeList><programme/></programmeList></Body></Packet>';*/
        /**@var PremiumInquiryResponse $response **/
        $response = $this->execute($request);
        if($response->isSuccess()){
            $response->buildCoverage($premiumInquiryVisitor->getVehicleVisitor()->isNewEnergy, $premiumInquiryVisitor->getCoverageVisitorList());
        }
        $nonCarInquiryPrinter = new NonCarInquiryPrinter();
        $totalPremium = 0;
        foreach ($premiumInquiryVisitor->getNonCarInquiryVisitor()->getNonCarList() as $item) {
            /*** @var $item NonCarProductVisitor */
            $single = new NonCarInquirySinglePrinter();
            $single->premium = $item->premium;
            $single->planCode = $item->planCode;
            $single->productCode = $item->productCode;
            $single->statusCode = 'success';
            $totalPremium += $single->premium * $item->insuredNum;
            $nonCarInquiryPrinter->noCarInquirySingleAppend($single);
        }
        $nonCarInquiryPrinter->totalPremium = $totalPremium;
        $response->printer->nonCarInquiryPrinter = $nonCarInquiryPrinter;
//        $testResponse = '';
        return $response;
    }

    /**
     * 核保
     * @param PremiumInquiryVisitor $premiumInquiryVisitor
     * @return
     */
    public function underwriting(PremiumInquiryVisitor $premiumInquiryVisitor)
    {
        $request = new UnderwritingRequest();
        $request->setVisitor($premiumInquiryVisitor);
        /**@var UnderwritingResponse $response **/
        $response = $this->execute($request);
//        //非车数据回填重构
//        /*** @var PremiumUnderwritingPrinter $printer */
//        $printer = $response->getPrinter();
//        if ($printer->noCarUnderwritingPrinter->statusCode == 'success' && !empty($premiumInquiryVisitor->getNonCarUnderwritingVisitor()->getNonCarList())) {
//
//            /*** @var NonCarProductVisitor $nonProduct */
//            $nonProduct = $premiumInquiryVisitor->getNonCarUnderwritingVisitor()->getNonCarList()[0];
//
//            $nonCarList = $printer->noCarUnderwritingPrinter->getNonCarInquiryList();
//
//            foreach ($nonCarList as &$value) {
//                /*** @var NonCarInquirySinglePrinter $value */
//                $value->productCode = $nonProduct->productCode;
//                $value->planCode = $nonProduct->planCode;
//            }
//        }

//        $response->printer = $printer;
        return $response;
    }

    /**
     * 获取支付链接
     * @param PolicyPaymentVisitor $paymentVisitor
     * @return
     */
    public function policyPayment(PolicyPaymentVisitor $paymentVisitor)
    {
        $request = new PolicyPaymentRequest();
        $request->setVisitor($paymentVisitor);

        /**@var PolicyPaymentResponse $response * */
        $response = $this->execute($request);

        return $response;
    }

    public function proposalStatus(ProposalStatusVisitor $proposalStatusVisitor)
    {
        $request = new OrderStatusQueryRequest();
        $request->setVisitor($proposalStatusVisitor);

        /**
         * @var OrderStatusQueryResponse $response
         */
        $response = $this->execute($request);
        return $response;
    }

    public function proposalRecall(ProposalRecallVisitor $revokeVisitor)
    {
        $request = new OrderCancelRequest();
        $request->setVisitor($revokeVisitor);

        /**
         * @var CancelOrderResponse $response
         */
        $response = $this->execute($request);
        return $response;
    }

    /**
     * 撤单接口
     * @param UnderwritingRecallVisitor $recallVisitor
     * @return CancelOrderResponse
     */
    public function underwritingRecall(UnderwritingRecallVisitor $recallVisitor)
    {
        $request = new OrderCancelRequest();
        $request->setVisitor($recallVisitor);

        /**
         * @var CancelOrderResponse $response
         */
        $response = $this->execute($request);
        return $response;
    }

    public function EPolicyDownload(EPolicyDownloadVisitor $EPolicyVisitor)
    {
        $request = new EPolicyDownloadRequest();
        $request->setVisitor($EPolicyVisitor);

        /**
         * @var EPolicyDownloadResponse $response
         */
        $response = $this->execute($request);
        return $response;
    }

    public function policyInfo(PolicyInfoVisitor $policyInfoVisitor)
    {
        $request = new OrderStatusQueryRequest();
        $request->setVisitor($policyInfoVisitor);

        /**
         * @var OrderStatusQueryResponse $response
         */
        $response = $this->execute($request);
        return $response;
    }


    public function UploadFile(UploadFileVisitor $uploadFileVisitor)
    {
        $request = new UploadFileRequest();
        $list = $uploadFileVisitor->fileList;
        $request->setVisitor($uploadFileVisitor);
        if (empty($list)) {
            throw new \Exception("图片不能为空");
        }
        $response = $this->execute($request);
        return $response;
    }



    /**
     * 非车产品列表
     * @param NonCarProductListVisitor $nonCarProductListVisitor
     * @return NonCarProductListResponse
     * @version 4.0
     */
    public function nonCarProductList(NonCarProductListVisitor $nonCarProductListVisitor): NonCarProductListResponse
    {
        $response = new NonCarProductListResponse(200);
        $response->printerInit();
        return $response;
    }

    public function nonCarInquiry(NonCarInquiryVisitor $nonCarInquiryVisitor)
    {
        // TODO: Implement nonCarInquiry() method.
    }

    public function nonCarUnderwriting(NonCarInquiryVisitor $inquiryPrinter)
    {
        // TODO: Implement nonCarUnderwriting() method.
    }
}
